package com.example.tyz1201.myaccount.Activity.Activity.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.tyz1201.myaccount.Activity.Activity.Model.DifferenceModel;
import com.example.tyz1201.myaccount.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by tyz1201 on 2016/4/12.
 */
public class DifferenceAdapter extends BaseAdapter {
    List<DifferenceModel> monthDifferenceMessages = new ArrayList<>();
    Context context;

    public DifferenceAdapter(List<DifferenceModel> monthDifferenceMessages, Context context) {
        this.monthDifferenceMessages = monthDifferenceMessages;
        this.context = context;
    }

    @Override
    public int getCount() {
        return monthDifferenceMessages.size();
    }

    @Override
    public Object getItem(int position) {
        return monthDifferenceMessages.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.item_month_difference, parent, false);

        TextView tv_md_date = (TextView) view.findViewById(R.id.tv_md_date);
        tv_md_date.setText(monthDifferenceMessages.get(position).getDate());

        TextView tv_md_num = (TextView) view.findViewById(R.id.tv_md_num);
        tv_md_num.setText(monthDifferenceMessages.get(position).getDifference() + "");
        return view;
    }
}
